package com.reebake.ideal.captcha.controller;

import com.reebake.ideal.captcha.client.CaptchaClient;
import com.reebake.ideal.captcha.core.SmartCaptchaService;
import com.reebake.ideal.captcha.entity.CaptchaRequestEntity;
import com.reebake.ideal.captcha.entity.CaptchaResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("captcha")
public class CaptchaClientController implements CaptchaClient {
    @Autowired
    private SmartCaptchaService smartCaptchaService;

    /***
     * 服务端验证接口，独立部署的场景使用，集成部署的场景：服务内部调用，不需要调用此接口，可注释掉
     * @param data 数据
     * @return 结果
     */
    @PostMapping("/verify")
    @Override
    public CaptchaResponseEntity verify(@RequestBody CaptchaRequestEntity data) {
        return smartCaptchaService.verify(data);
    }

}
